package com.kangtu.demoaskpager.util;

/**
 * @program: demo-weix-pay
 * @description: ResponseResult
 * @author: 亮子说编程
 * @create: 2021-03-23 18:30
 **/
public class ResponseResult {
    boolean success = true;
    int code = 1000;
    String message;
    private Object result;

    public ResponseResult() {
        this.code = 0;
        this.message = "操作成功";
    }

    public ResponseResult(boolean success, int code, String message) {
        this.success = success;
        this.code = code;
        this.message = message;
    }

    public ResponseResult(boolean success, int code, String message, Object result) {
        this.success = success;
        this.code = code;
        this.message = message;
        this.result = result;
    }

    public static ResponseResult SUCCESS() {
        return new ResponseResult(true, 1000, "操作成功");
    }

    public static ResponseResult SUCCESS(Object result) {
        return new ResponseResult(true, 1000, "操作成功", result);
    }

    public static ResponseResult FAIL() {
        return new ResponseResult(false, 1111, "操作失败");
    }

    public static ResponseResult FAIL(String message) {
        return new ResponseResult(false, -1, message);
    }

    public static ResponseResult FAIL(int code, String message) {
        return new ResponseResult(false, code, message);
    }

    public void setFailMessage(String message) {
        this.success = false;
        this.code = -1;
        this.message = message;
    }

    public void setFailMessage(int code, String message) {
        this.success = false;
        this.code = code;
        this.message = message;
    }

    public boolean isSuccess() {
        return this.success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public int getCode() {
        return this.code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getResult() {
        return this.result;
    }

    public void setResult(Object result) {
        this.result = result;
    }

    @Override
    public String toString() {
        return "ResponseResult{success=" + this.success + ", code=" + this.code + ", message='" + this.message + '\'' + ", result=" + this.result + '}';
    }
}
